﻿@using SmartStore.Web.Models.Search
@model SearchResultModel
@{ 
	var hasThumbs = Model.TopProducts.Items.Any(x => x.Picture != null && x.Picture.ImageUrl.HasValue());
}

<ul class="instasearch-hits@(hasThumbs ? " has-thumbs" : "")">
	@foreach (var hit in Model.TopProducts.Items)
	{
		<li>
			<a class="instasearch-hit" href="@Url.RouteUrl("Product", new { SeName = hit.SeName })">
				<span class="instasearch-hit-wrapper">
					@if (hasThumbs && hit.Picture != null && hit.Picture.ImageUrl.HasValue())
					{
						<span class="instasearch-hit-thumb d-block">
							<img src="@hit.Picture.ImageUrl" alt="" class="img-fluid" />
						</span>
					}
					<span class="d-block text-truncate">
						<span class="d-block text-truncate" @Html.LanguageAttributes(hit.Name)>
							@Html.Raw(Model.Highlight(hit.Name, "name", Model.Query, null, "<span class='instasearch-match'>", "</span>"))
						</span>
						@if (hasThumbs && hit.ShortDescription.Value.HasValue())
						{
							<span class="instasearch-hit-label-secondary d-block text-truncate" @Html.LanguageAttributes(hit.ShortDescription)>
								@hit.ShortDescription.Value.RemoveHtml()
							</span>
						}
					</span>
				</span>
			</a>
		</li>
	}
</ul>